package com.website.web.back.controller.website;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.website.common.annotation.Log;
import com.website.common.enums.BusinessType;
import com.website.custom.domain.WBrand;
import com.website.custom.service.IWBrandService;
import com.website.common.core.controller.BaseController;
import com.website.common.core.domain.AjaxResult;
import com.website.common.utils.poi.ExcelUtil;
import com.website.common.core.page.TableDataInfo;

/**
 * 品牌文化Controller
 * 
 * @author ruoyi
 * @date 2024-12-03
 */
@Controller
@RequestMapping("/back/custom/brand")
public class WBrandController extends BaseController
{
    private String prefix = "back/website/brand";

    @Autowired
    private IWBrandService wBrandService;

    @RequiresPermissions("system:brand:view")
    @GetMapping()
    public String brand()
    {
        return prefix + "/brand";
    }

    /**
     * 查询品牌文化列表
     */
    @RequiresPermissions("system:brand:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WBrand wBrand)
    {
        startPage();
        List<WBrand> list = wBrandService.selectWBrandList(wBrand);
        return getDataTable(list);
    }

    /**
     * 导出品牌文化列表
     */
    @RequiresPermissions("system:brand:export")
    @Log(title = "品牌文化", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WBrand wBrand)
    {
        List<WBrand> list = wBrandService.selectWBrandList(wBrand);
        ExcelUtil<WBrand> util = new ExcelUtil<WBrand>(WBrand.class);
        return util.exportExcel(list, "品牌文化数据");
    }

    /**
     * 新增品牌文化
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存品牌文化
     */
    @RequiresPermissions("system:brand:add")
    @Log(title = "品牌文化", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WBrand wBrand)
    {
        return toAjax(wBrandService.insertWBrand(wBrand));
    }

    /**
     * 修改品牌文化
     */
    @RequiresPermissions("system:brand:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WBrand wBrand = wBrandService.selectWBrandById(id);
        mmap.put("wBrand", wBrand);
        return prefix + "/edit";
    }

    /**
     * 修改保存品牌文化
     */
    @RequiresPermissions("system:brand:edit")
    @Log(title = "品牌文化", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WBrand wBrand)
    {
        return toAjax(wBrandService.updateWBrand(wBrand));
    }

    /**
     * 删除品牌文化
     */
    @RequiresPermissions("system:brand:remove")
    @Log(title = "品牌文化", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wBrandService.deleteWBrandByIds(ids));
    }
}
